{include_file name="Public/header" title="{if $info}编辑{else}添加{/if}文章"}

    <!-- begin #content -->
    <div id="content" class="content">

        <!-- begin page-header -->
        <h1 class="page-header">{if $info}编辑{else}添加{/if}文章<small><a href="{U("{CONTROLLER_NAME}/index")}" class="btn btn-success btn-sm">文章列表</a></small></h1>
        <!-- end page-header -->


        <!-- begin row -->
        <div class="row">
            <!-- begin col-6 -->
            <div class="col-md-12 ">
                <!-- begin panel -->
                <div class="panel panel-inverse" data-sortable-id="form-stuff-2">
                    <form action="{$action_url}" method="POST" class="margin-bottom-0" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="{$info.id}">
                        <div class="panel-body">


                            <fieldset>

                                <div class="form-group">
                                    <label>文章标题：(<span class="label-tip">*必填</span>)</label>
                                    <input type="text" name="data[title]" value="{$info.title}" class="form-control" placeholder="" datatype="*2-250" errormsg="请输入2-250汉字或字符">
                                    <span class="Validform_checktip"></span>
                                </div>

                                <div class="form-group js_uploadBox">
                                    <label>文章封面：(<span class="label-tip">建议尺寸：宽度800px,高度不限</span>)</label>
                                    <div class="btn-upload">
                                        <a href="javascript:void(0);"><i class="fa fa-download"></i><span class="js_uploadText">上传</span>封面</a>
                                        <input class="js_upPic" type="file" name="cover">
                                    </div>

                                    <div class="js_showBox {if !$info.cover}hidden{/if}"><img class="js_logoBox" src="{_image($info.cover)}" width="400px"></div>
                                </div>

                                <div class="form-group">
                                    <label>文章简介：(<span class="label-tip">*必填</span>)</label>
                                    <textarea rows="4"  name="data[intro]" class="form-control" placeholder="" datatype="*2-250" errormsg="请输入2-250汉字或字符">{$info.intro}</textarea>
                                    <span class="Validform_checktip"></span>
                                </div>


                                <div class="form-group">
                                    <label>文章内容：(<span class="label-tip">*必填</span>)</label>
                                    {W('Editor/kindeditor', array('data[content]', "{$info.content}",  '100%', '600px'))}
                                    <span class="Validform_checktip"></span>
                                </div>

                                <div class="form-group">
                                    <label>发布时间:</label>
                                    <input type="text" name="data[add_time]" readonly class="form-control js_add_time width-xs" value="{date('Y-m-d H:i:s')}" placeholder="" id="dp1466946455315">
                                    <span class="Validform_checktip"></span>
                                </div>

                                <div class="form-group">
                                    <label>文章状态：</label>
                                    <input type="radio" name="data[status]" value="1" class="form-group" checked>是
                                    <input type="radio" name="data[status]" value="0" class="form-group" >否
                                    <span class="Validform_checktip"></span>
                                </div>

                                <button type="submit" class="btn btn-sm btn-primary m-r-5 js_submit">提交</button>
                            </fieldset>

                        </div>
                    </form>

                </div>
            </div>
            <!-- end panel -->
        </div>
        <!-- end col-6 -->
        <!-- end row -->
    </div>
    <!-- end #content -->

<!--上传前预览插件，更多用法请访问http://www.gouguoyin.cn/js/81.html-->
<link href="{STATIC_PLUG}/jquery-uploadview/jquery.uploadview.css?v={VERSION}" rel="stylesheet" />
<script  type="text/javascript"  src="{STATIC_PLUG}/jquery-uploadview/jquery.uploadview.js"></script>

<!--日期、时间选择插件，更多用法参考http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm-->
<script type="text/javascript" src="{STATIC_PLUG}/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="{STATIC_PLUG}/bootstrap-datetimepicker/js/bootstrap-datetimepicker.zh-CN.js"></script>

<script>
    $(document).ready(function() {
        //上传图片预览
        $(".js_upPic").uploadView({
            'uploadBox': '.js_uploadBox',
            'showBox' : '.js_showBox',
            'width' : 300,
            //'height': 300,
            allowType: ["gif", "jpeg", "jpg", "bmp", "png"], //允许上传图片的类型
            maxSize :1, //允许上传图片的最大尺寸，单位M
            //上传成功的回调函数
            success:function(e){
                $(".js_uploadText").text('更改');
                $(".js_showBox").removeClass("hidden");
                //alert('图片上传成功');
            }
        });

        //时间选择插件
        $(".js_add_time").datetimepicker(
                {
                    language:  'zh-CN',
                    format: 'yyyy-mm-dd hh:ii:ss',
                    weekStart: 1,
                    todayBtn:  1,
                    autoclose: 1,
                    todayHighlight: 1,
                    startView: 2,
                    minView: 2,
                    forceParse: 0
                }
        );

        //表单验证
        $("form").Validform({

            tiptype:function(msg,o,cssctl){

                if(!o.obj.is("form")){
                    var objtip=o.obj.siblings(".Validform_checktip");
                    cssctl(objtip,o.type);
                    objtip.text(msg);
                }

            },

            label:"label",

            //ajaxPost:true,

            btnSubmit:".js_submit",

            beforeSubmit:function(){

                editor.sync();

                $(".js_submit").attr("disabled", "disabled").text('提交中..');

            },


        });

    });
</script>

<!-- end page container -->

{include_file name="Public/footer"}